grammar Code;

range  : range op range                                         #Assoc
       | range range                                            #Add
       | '{' range '}'                                          #Simple
       | ('['|'(') start comma speed comma end (')'|']')        #SSE
       | ('['|'(') start comma end (')'|']')                    #SE
       | ('['|'(') start (')'|']')                              #S
       ;

start   :   INT;
speed   :   '%'? INT;
end     :   INT;

op      :   ADDOPTION
        |   SUBOPTION
        |   MixOPTION
        ;

comma   :   ',';

SMALLBRACKETLEFT    :   '(';
SMALLBRACKETRIGHT    :   ')';
MEDIUMBRACKETLEFT   :   '[';
MEDIUMBRACKETRIGHT   :   ']';
ADDOPTION   :   '+';
SUBOPTION   :   '-';
MixOPTION   :   '^';

INT         :   [0-9]+;
NL          :   '\r'?'\n';
WS          :   [ \t\r\n]+ -> skip;